package com.neutech.controller;

import com.neutech.service.PtestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class PtestController {

    @Autowired
    private PtestService ptestService;

    @ResponseBody
    @RequestMapping("/nameptest")
    public List<Map<String, Object>> queryPtestByName(@RequestParam Map map)
    {

        //List<Map<String, Object>> list = confirmService.queryConfirmByName(map.get("name").toString()));
        List<Map<String, Object>> list = ptestService.queryPtestByName(map.get("name").toString());
        System.out.println(list);
        return ptestService.queryPtestByName(map.get("name").toString());

    }

    @ResponseBody
    @RequestMapping("/mestest")
    public List<Map<String, Object>> queryTestByName(@RequestParam Map map)
    {


        List<Map<String, Object>> list = ptestService.queryTestByName(map.get("name").toString());
        System.out.println(list);
        return list;

    }
    @ResponseBody
    @RequestMapping("/addptest")
    public void addPtest(@RequestParam Map map)
    {
        for (Object key : map.keySet())
        {
        String value = (String)map.get(key);

        System.out.println(key + " : " + value);
        }
    ptestService.addPtest(map);
    }

    @ResponseBody
    @RequestMapping  ("/delptest")
    public void delptest(@RequestParam Map map)
    {
        System.out.println(map.get("num"));
        ptestService.delptest(Integer.parseInt(map.get("num").toString()));

    }
    @ResponseBody
    @RequestMapping  ("/idptest")
    public List<Map<String, Object>> idptest(@RequestParam Map map)
    {
        System.out.println(map.get("idnumber"));
       return ptestService.queryPtestByIdnumber(Integer.parseInt(map.get("idnumber").toString()));

    }

}
